package db.common;

import java.sql.*;


public class DBHelper {

	private static final String URL = "jdbc:mysql://localhost:3306/smms";
			//+ "?characterEncoding=utf-8&characterSetResults=utf-8";
	private static final String USER = "root";
	private static final String PASSWORD = "zou123456";

	public static Connection conn = null;

	static {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(URL, USER, PASSWORD);
			Statement stmt = conn.createStatement();
			ResultSet rs=stmt.executeQuery("select employeeId,employeeName from tab_employee ");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static Connection getConnection(){
		return conn;
	}

	
	public static void main(String[] args) throws SQLException {
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select employeeId,employeeName from tab_employee ");
		while (rs.next())
			System.out.println(rs.getInt("employeeId") + "," + rs.getString("employeeName"));
	}


	public static void close(ResultSet rs) {
		
		
	}

}
